/*
 * Copyright (c) 2010 Sun Microsystems, Inc.
 * Copyright (c) 2011 Oracle Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **/

package org.sunspotworld.demo;

import com.sun.spot.wot.NanoAppServer;
import com.sun.spot.wot.TCPHandler;
import java.io.IOException;

/**
 * Sample Sun SPOT host application
 */
public class Main {
    /**
     * Start up the host application.
     *
     * @param args any command line arguments
     */
    public static void main(String[] args) {
        NanoAppServer nas = new NanoAppServer();

        nas.registerApp("/echo", new EchoApp("n=Echo Service\nsh=e\nct=0"));
        nas.registerApp("/date", new DateApp("n=Date Service\nd=http://en.wikipedia.org/wiki/Date\nsh=d\nct=0"));
        //ar.setDefaultApp(new DateApp());

        try {
            new TCPHandler(9999, nas).start();
            // Before uncommenting this line, make sure that a reverse HTTP
            // gateway is running on sensor.network.com at port 1234. Also,
            // replace xxxx with the last four hex digits of your basestation's
            // address (xxxx just needs to be a unique string that won't conflict
            // with the string chosen by any another user who may be running an
            // RHHTPHandler that connects up to sensor.network.com:1234)
//            new RHTTPHandler("http://sensor.network.com:1234/xxxx",
//                    "/xxxx".length(), nas).start();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
